/*
* FILENAME:		errhandle.c/errhandle.h 
* CREATED AT:		2012/Jun/3
* DECRITION:		defines all the opearation error code, the global errlist
* 
* MODULE:		error handling
* PLATFORM:		ubuntu-12.04/gcc-4.6.3
* AUTHOR:		incarnation-lee
* 
* ----------------------REVISION HISTROY------------------------
* No.	Date	Revised by	Function	Descrition
* 1	12/6/3	incar-lee	NA		created 
*/

/* Standard C */
#include <stddef.h>

/* linux related */
#include <fcntl.h>
#include <sys/types.h>

/* user defined */
#include "externals.h"
#include "errhandle.h"
#include "errcode.h"
#include "udgtd.h"


ErrCode g_err_code = NoERROR;						/* 0 sucess, no error */

static const char *errlist[]={
	"no error at all.\n",						/* 0 */
	"operate on a uninitiliazied data struct or not exist.\n",	/* 1 */
	"fail to get memory from system call, malloc.\n",		/* 2 */
	"invalid index value.\n",					/* 3 */
	"no more space for operation of data structure.\n",		/* 4 */
	"the value of some field in data structure inconsistent.\n",	/* 5 */
};


/*
* set the error number 
*/
void set_errcode(ErrCode Ecode)
{
	g_err_code = Ecode;
}


/*
* print the string error msg
*/
void str_error()
{
	fprintf(stdout,"error code:%d,msg:%s",g_err_code,errlist[g_err_code]);
}
